<?php
/**
 +--------------------------
 * 公共函数库
 +--------------------------
 */

class Pub{
	public $ModelCacheData;
	public function sayHello(){
		echo 2222;
		exit;
	}
	static function csv($data,$field='',$title='csv',$suf='csv',$top=true, $sep_char = ','){
		$filename = iconv("UTF-8", "GBK",date('y-m-d').'_'.$title).'.'.$suf;
	
		$csv = new ParseCsv();
		$csv->output_filename = null;
		$data = $csv->output (null, $data, $field);
	
		header('Content-Type: text/html; charset=utf-8');
		header("Content-type: application/csv");
		header('Content-Disposition: attachment; filename='.$filename);
		echo mb_convert_encoding($data,'GB2312', 'UTF-8');
		exit;
	}
	
	static function url($p,$absoluteUrl=true){
		list($cmd,$p)= explode('?',$p);
		list($m,$a)= explode('/',$cmd.'/index/index');
		$httpHost = $absoluteUrl? 'http://'.$_SERVER['HTTP_HOST'] :'';
		return $httpHost.__APP__."?m=$m&a=$a&$p";
	}
	
}